package com.cdzs.twocamera;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

import com.cdzs.twocamera.util.SPUtils;
import com.serenegiant.common.BaseActivity;

import ch.ielse.view.SwitchView;


public class SettingActivity extends BaseActivity {

    private SwitchView svFireControlMode;
    private Button btnSure;
    private SwitchView sv_peak_mode;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);

        initView();

    }

    private void initView() {
        svFireControlMode = findViewById(R.id.sv_fireControl_mode);
        svFireControlMode.setOnStateChangedListener(new SwitchView.OnStateChangedListener() {
            @Override
            public void toggleToOn(SwitchView view) {
                view.toggleSwitch(true); // or false
                SPUtils.setSharedBooleanData("fireMode", true);
            }

            @Override
            public void toggleToOff(SwitchView view) {
                view.toggleSwitch(false); // or true
                SPUtils.setSharedBooleanData("fireMode", false);
            }
        });

        sv_peak_mode = findViewById(R.id.sv_peak_mode);
        sv_peak_mode.setOnStateChangedListener(new SwitchView.OnStateChangedListener() {
            @Override
            public void toggleToOn(SwitchView view) {
                view.toggleSwitch(true); // or false
                SPUtils.setSharedBooleanData("peakMode", true);
            }

            @Override
            public void toggleToOff(SwitchView view) {
                view.toggleSwitch(false); // or true
                SPUtils.setSharedBooleanData("peakMode", false);
            }
        });

        btnSure = findViewById(R.id.btn_sure);
        btnSure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                startActivity(new Intent(SettingActivity.this,MainActivitySurface.class));
                finish();
            }
        });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.d("keyCode", "keyCode:" + keyCode);

        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        }

        return super.onKeyDown(keyCode, event);
    }
}
